﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using System.Data;

namespace TrabalhoWeb
{
    public partial class UserControlListaContas : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Contas objDal = new Contas();

            //Popula o gridview com o retorno da lista das contas cadastradas
            grvListaContas.DataSource = objDal.ListarContas();
            grvListaContas.DataBind();

            grvContas.DataSource = objDal.ListarContas(1);
            grvContas.DataBind();


           
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

        }

        public void PreencherConta(int Categoria)
        {
            Contas objContas = new Contas();
            DataTable dttContas = new DataTable();
            dttContas = objContas.ListarContas(Categoria);

           // grvContas.DataSource = objContas.ListaContas(0, Categoria);
           // grvContas.DataBind();
        }

        protected void grvListaContas_SelectedIndexChanged(object sender, EventArgs e)
        {
        
        }

        protected void grvListaContas_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Consultar":

                    PreencherConta(Convert.ToInt32(e.CommandArgument));

                    break;
            }
        }

        protected void grvContas_RowCommand(object sender, GridViewCommandEventArgs e)
        {

        }

        
    }
}